package cn.walnut.web.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @program: walnut-security
 * @Date: 2018/12/19 14:04
 * @Author: Walnut1992
 * @Description:
 */
@Aspect
@Component
public class TimeAspect {

    @Around("execution(* cn.walnut.controller.UserController.*(..))")
    public Object handleControllerMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        System.out.println("time aspect开始");
        long time = new Date().getTime();
        Object proceed = proceedingJoinPoint.proceed();
        Object[] args = proceedingJoinPoint.getArgs();
        for (Object arg : args) {
            System.out.println("arg:" + arg);
        }
        System.out.println("time aspect耗时:" + (new Date().getTime() - time));
        return proceed;
    }
}
